package com.sq.partner.manager.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sq.partner.manager.dao.ICoreDeptDao;
import com.sq.partner.manager.dao.IGatewayRoleDao;
import com.sq.partner.manager.dao.IGatewayRoleDeptDao;
import com.sq.partner.manager.mybatis.model.GatewayRole;
import com.sq.partner.manager.mybatis.model.GatewayRoleMenu;
import com.sq.partner.manager.mybatis.model.GatewayUser;
import com.sq.partner.manager.mybatis.model.GatewayUserRole;
import com.sq.partner.manager.mybatis.model.TreeDto;
import com.sq.partner.manager.service.IGatewayRoleService;
import com.sq.partner.manager.util.Page;
@Service
public class GatewayRoleServiceImpl implements IGatewayRoleService {
	
	@Resource
	private IGatewayRoleDao roleDao;
	@Resource
	private ICoreDeptDao coreDeptDao;
	
	@Override
	public Page queryPage(Page page, Integer pageIndex, GatewayRole role,GatewayUser user)
			throws Exception {
		return roleDao.queryPage(page, pageIndex, role,user);
	}
	
	@Override
	public boolean deleteRole(GatewayRole role) throws Exception {
		return roleDao.deleteRole(role);
	}
	
	@Override
	public Long addRole(GatewayRole role) throws Exception {
		return roleDao.addRoleAndReturnKey(role);
	}

	@Override
	public GatewayRole queryRoleNameExistsOrNot(Map<String, String> map)
			throws Exception {
		return roleDao.queryRoleNameExistsOrNot(map);
	}

	@Override
	public boolean modifyRole(GatewayRole role) throws Exception {
		return roleDao.modifyRole(role);
	}

	@Override
	public boolean delUserRoleRoleid(Long   roleid) throws Exception {
		GatewayUserRole userRole = new GatewayUserRole();
		userRole.setRoleid(roleid);
		return roleDao.delUserRoleRoleid(userRole);
	}
}
